Notes
{labels: 'NIL, viewFont: 10241} // nil=Unfiled, or specify a folder, e.g., 'Business.  remove viewFont for current Styles default
//ERASE! remove initial // to erase existing entries in this folder first

dontask.nwt -- Slurpee format
31 Oct 96
Copyright 1995-96 S. Weyer.  All Rights Reserved Worldwide.

Revision History:

31 Oct 96 (see ***)
added DoNotInstall method to prevent installation on NOS 2.0 Newtons

30 Jul 95
init				added func() so that it would be recognized as a method
viewSetupChildren	added inherited:?  (though not currently necessary)
viewDrawScript		added exists test to avoid error during development
viewSetupFormScript	added this to patch a problem in the standard keyboard
  (Serg Koren reported a problem where if you "close" a keyboard with a
  prompt via a kbd icon rather than close box, the keyboard came up later
  with prompt overwriting top row of keys.  This occurred whether or not
  DontAsk was installed.)


Keywords: keyboard, prompt, source, Newt

Don't Ask (Don't Tell) is a simple, tiny app (autopart) that adds a button (at
lower left) in the standard keyboard so that you can turn off/on the "Do you
want to add..." prompt, which you may find annoying or sometimes desirable...

When dot is hollow (default), words pass through to the dictionary prompt.
When dot is solid, the dictionary prompt does not appear (it's blocked/overridden).

This Newt source file (dontask.nwt) and the associated Newt-generated
package (DontAsk.pkg) are shareware ($5) and may be distributed freely as
long as both files are included and unmodified.  You are free to make
modifications for your own use.

For your convenience, I have attached a package generated by the Newt
Development Environment* so that you don't have to compile & save this
yourself -- just install using NCK, Package Installer or a shareware
downloader. If you would like to build or modify the Don't Ask application,
you can use Newt (3.3 or greater) (see directions at end); you can avoid
re-entering the source by transferring dontask.nwt with a utility such as
Slurpee (1.9).

*Newt is an environment for developing applications using NewtonScript and
saving as packages directly on your Newton (you can also use a PC or Mac for
source editing and application debugging). Newt is shareware -- registered
users receive files containing current releases, additional packages, 200+
source examples, and a 80+ pp. Acrobat manual describing Newt
features and NewtonScript syntax and functions.

For more information, browse
  http://www.netaxs.com/~weyer/newton/releases.html
or consult the Newt FAQ on AOL, Compuserve, ftp.amug.org
or send me email: weyer@netaxs.com.
----------
Disclaimers: Although Don't Ask relies on UNDOCUMENTED behavior of the
built-in keyboard, it should work on most 1.x configurations (it will not
install on NOS 2.0). It appears not to interfere with the Graffiti kbd patch
-- either in setup behavior or location (Graffiti button appears on right,
DontAsk on left). If you're aware of keyboard related conflicts, let me know
and I will contact other developers to see if we can coordinate our patches.

DontAsk generally installs & removes itself properly.  However, if it is
installed on a card and you remove the card while the keyboard is open, you
will get a "Newton Still Needs the Card" message (just close the kbd first;
or install DontAsk in internal; or we could modify the button to consume more
heap).

Implementation notes: this could be even simpler -- don't add a button, just
always turn off the prompt -- but it seemed to me that there might be
occasions where you might want to turn prompting back on.  It could be more
complex -- behavior controlled via a Preference panel, but that would
require many taps to switch back and forth.

You can send questions, feature requests, and registrations for DontAsk ($5)
or Newt ($45) [please include your email address, if any] to:

Steve Weyer
17 Timber Knoll Drive
Washington Crossing, PA 18977-1052
Internet: weyer@netaxs.com
http://www.netaxs.com/~weyer/newton/releases.html
America Online/: SteveWeyer
Compuserve: 74603,2051

Since DontAsk is such a simple app, I don't have any major enhancements planned.
If you do register, you'll encourage me to write, release (and inform you
about) other utilities and source examples.
----------
init
//:init()
func()
begin
	:DefConst('kSize,5); // dot size
end
----------
DontAsk
//:doObj('build,'DontAsk)
//:saveApp(DontAsk)
{// a simple "button".
// a checkbox might be nicer but there's no really no room in kbd
// and adding a Preference panel seems very inconvenient to user
// note: constants can be defined symbolically with optional viewcnst.pkg plug-in

viewclass: clView, // just a vanilla view
viewFlags: 513,    // vClickable + vVisible
viewBounds: RelBounds(22,-7,kSize,kSize), // left,top,width,height. left&top relative to left&bottom, between Dict icon & Option
viewJustify: 128,  // vjParentBottomV (left, bottom aligned)
viewDrawScript: func()
	:DrawShape(MakeOval(0,0,kSize,kSize), // left,top,right,bottom
		{transferMode: 0, // modeCopy
		fillPattern:
			if askWords exists and askWords // may be undefined initially during devel
			then 0  // vfFillWhite
			else 5, // vfFillBlack
			}),

viewClickScript: func(unit)
	begin
		askWords := not askWords; // toggle in parent (alphakeyboard)
		:dirty(); // redraw. returns TRUE
	end,

_package: {
	version: 11,
	copyright: "\u00A9\u 1995-96, S. Weyer.",
	devSignature: "TKnollSys", // appSymbol => DontAsk:TKnollSys 

	//installScript -- add these separately for editing convenience
	//removeScript
	//partData -- this is an autopart
	DoNotInstall: func() TRUE, // this prevents installation on NOS 2.0 ***. ignored by 1.x
	},
}
----------
DontAsk._package.installScript
//:installApp(DontAsk,true)
func(partFrame,removeFrame)
// this only installs (and works) on 1.x Newtons (see DoNotInstall function)
begin
	local slot,val, kbd := GetRoot().alphaKeyboard;
	// we could check visibility & redo children. simpler just to close it...
	kbd:close();

	// copy some values into built-in keyboard VIEW
	// and stash slots in removeFrame for later cleanup
	foreach slot,val in partFrame.partData
	do begin
		slot := EnsureInternal(slot);
		removeFrame.(slot) := kbd.(slot) := val;
		end;

	// button appears next time kbd opened
end
----------
DontAsk._package.removeScript
//:installApp(DontAsk,nil)
func(removeFrame)
begin
	local slot, val, kbd := GetRoot().alphaKeyboard;
	// we could check visibility & redo children. simpler just to close it...
	kbd:close(); // if kbd still open & card is removed, then "Newton Still Needs the Card" !

	// remove slots we added in installScript
	foreach slot,val in removeFrame
	do RemoveSlot(kbd,slot);
end
----------
DontAsk._package.partData
{// slots to add to the keyboard view

// this is set each system reset/card insertion; could store in a system preference?
askWords: true, // prompt as usual (default). modified in DontAsk.viewClickScript. used in kbd.keywordScript & DontAsk.viewDrawScript

dontAskTemplate: DontAsk._proto, // the "button" template, to be added as a child in kbd.viewSetupChildrenScript

keywordScript: func(x)
	if askWords
	then inherited:keywordScript(x) // default (prompt) behavior
	else NIL, // don't prompt

viewSetupChildrenScript: func()
	if shrunken // only do this if prompt isn't being displayed
	then begin
		// I think Graffiti patch adds a viewSetupFormScript method 
		// and sets stepChildren there, so this seems to peacefully coexist...
		if not stepChildren
		then stepChildren := [];
		AddArraySlot(stepChildren,dontAskTemplate);
		end
	else inherited:?viewSetupChildrenScript(), // not really necessary, but just in case...

viewSetupFormScript: func()
	begin
		inherited:viewSetupFormScript();
		// fix a bug in the standard keyboard
		// viewBounds is wrong if kbd icon was used to "close" while a prompt was up
		// don't worry about cloning since shrunken is true initially
		if not shrunken and
			(viewBounds.bottom-viewBounds.top) = (saveBounds.bottom-saveBounds.top)
		then viewBounds.top := viewBounds.top - 22;
	end,
}
----------
I will provide a few suggestions here on how to modify, build & test this
application. Of course, I would recommend registering for Newt to obtain more
documentation and examples...

- transfer source to the Notepad (use Slurpee, NCK or ...)

- install Newt 3.3 & NewtPack.

- if you installed the DontAsk:TKnollSys package, remove it via Card:Remove Software;
or, use Remove Package command (under action button) once you are in Newt --
otherwise, you won't be able to install&test during development (though you could
just build & save(replace)).

- start Newt. select folder with source (default is Unfiled)

- make any edits, for example:
  change location of button, RelBounds(21,-8,kSize,kSize) in DontAsk's viewBounds slot // move left & up 1
  change shape of button, MakeRect instead of MakeOval in DontAsk's viewDrawScript method
  change size of button, :DefConst('kSize,7) in init method
    to redefine constant. tap Expr. select :init(). tap Eval
  change fill of button, 4 (for vfFillDkGray) instead of 5 (for vfFillBlack)
    in DontAsk's viewDrawScript method
  so, now button would be a 7x7 square instead of 5x5 circle

- build application:  tap Expr. select :doObj('build,'DontAsk).  Eval

- install application temporarily (run its installScript, etc.)
  tap Expr.  select :installApp(DontAsk,true). Eval

- double-tap in text area to get standard keyboard (or use Newt's keyboard icon).

- optional. tap Expr. select :installApp(DontAsk,nil). Eval
  to un-install app.  (this isn't strictly necessary since build or save
  ensure it is un-installed).

- possibly iterate through additional edit/build/install cycles.

- to save package, tap Expr. select :saveApp(DontAsk). Eval

- exit Newt. double-tap to see keyboard.

- to confirm installScript/removeScript behavior
  close keyboard
  unlock or remove card
  double-tap to get keyboard (no button should be present)
  lock or insert card
  keyboard closes (if open)
  double-tap for keyboard (button should be present)

- congratulations! you have just created, tested and installed a custom autopart

- to give the new package to your friends:
  backup Newton using NCK.
use Extract Package application (see
www.netaxs.com/~weyer/newton/releases.html for URLs for Mac and Windows
versions) to extract package from NCK bacup file. (Windows version may
display package name generically as "package0xxxx" -- you can compare size
of file with package in Newton's Remove Software/Package menu)
---------
BYE!
